WOLFRAM NOTEBOOK

The functions
TakeLargest
,
TakeLargestBy
,
TakeSmallest
, and
TakeSmallestBy
provide simple ways of selecting elements from lists and associations by numerical order.
For each South American country, associate the life expectancy of its inhabitants and the gross domestic product (GDP) at purchasing power parity (PPP):
In[1]:=
data=EntityValue
South America
COUNTRIES
,
life expectancy
,
GDP|CurrentUSDollar;PPP
,"EntityAssociation"
Out[1]=
Argentina
76.305
yr
,
$
4.68499×
11
10
per year
,
Bolivia
67.26
yr
,
$
7.37957×
10
10
per year
,
Brazil
73.937
yr
,
$
3.1924×
12
10
per year
,
Chile
79.955
yr
,
$
4.00534×
11
10
per year
,
Colombia
74.038
yr
,
$
6.65594×
11
10
per year
,
Ecuador
76.471
yr
,
$
1.83855×
11
10
per year
,
Falkland Islands
Missing[NotAvailable],
$
1.051×
8
10
per year
,
French Guiana
77.121
yr
,
$
1.551×
9
10
per year
,
Guyana
66.295
yr
,
$
5.75808×
9
10
per year
,
Paraguay
72.259
yr
,
$
6.0977×
10
10
per year
,
Peru
74.826
yr
,
$
3.89147×
11
10
per year
,
Suriname
71.019
yr
,
$
9.21404×
9
10
per year
,
Uruguay
77.23
yr
,
$
7.2751×
10
10
per year
,
Venezuela
74.633
yr
,
$
5.54329×
11
10
per year
Use
TakeSmallest
to get the two countries with the lowest life expectancy:
In[2]:=
c1=TakeSmallest[data[[All,1]],2]
Out[2]=
Guyana
66.295
yr
,
Bolivia
67.26
yr
TakeLargest
gives the two countries with the largest GDP at PPP:
In[3]:=
c2=TakeLargest[data[[All,2]],2]
Out[3]=
Brazil
$
3.1924×
12
10
per year
,
Colombia
$
6.65594×
11
10
per year
Emphasize with colors these two sets of countries on a geographical map:
In[4]:=
GeoGraphics[{Red,Polygon[Keys@c1],Green,Polygon[Keys@c2]}]
Out[4]=
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.